//
//  HitView.m
//  NVAReader
//
//  Created by DuyLK on 6/19/14.
//  Copyright (c) 2014 com.nva.nvareader. All rights reserved.
//

#import "HitView.h"
#include "common.h"
@implementation HitView

-(id) init
{
    self = [super init];
    return self;
}
- (id) initWithSearchResults: (int)n forDocument: (fz_document *)doc
{
    self = [super init];
	if (self) {
		for (int i = 0; i < n && i < nelem(hitRects); i++) {
			fz_rect bbox = search_result_bbox(doc, i); // this is thread-safe enough
			hitRects[i].origin.x = bbox.x0;
			hitRects[i].origin.y = bbox.y0;
			hitRects[i].size.width = bbox.x1 - bbox.x0;
			hitRects[i].size.height = bbox.y1 - bbox.y0;
		}
		_hitCount = n;
	}
	return self;
}
- (CGRect*)getHitSearch
{
    return hitRects;
}
- (void) dealloc
{
	int i;
	[color release];
	for (i = 0; i < _hitCount; i++)
		free(linkUrl[i]);
	[super dealloc];
}
@end
